package yqt.com.cnki.controller;

import haha.life.common.CutPageBean;
import haha.life.normal.TpiUtils;
import io.swagger.annotations.ApiOperation;
import jzqb.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yqt.com.cnki.bo.QBKJBo;
import yqt.com.cnki.po.QBKJPo;
import yqt.com.cnki.service.IQBKJService;

import java.util.List;
import java.util.Map;

/**
 * Description: 情报科技
 *
 * @author BaiGe
 * @date: 2021/12/22 14:22
 * @Version 1.0
 */
@RestController
@RequestMapping("/kjqb")
public class QBKJController {
    @Autowired
    private TpiUtils tpiUtils;
    //情报科技表名
    private static String dataBaseCode = "YQTQBKJ";
    @Autowired
    private IQBKJService qbkjService;


    @ApiOperation(value = "获取分类树")
    @GetMapping("/getClsTree")
    public Object getClsTree() {
        List<Map<String, Object>> maps = tpiUtils.excuteQueryList(dataBaseCode, false);
        List<Map<String, Object>> describeMap = tpiUtils.getDescribe("YQTQKKJZTK");
        //导航树添加描述
        for (Map map : maps) {
            List<Map<String, String>> childList = (List<Map<String, String>>) map.get("child");
            if (childList.size() == 0) {
                continue;
            }
            for (Map cMap : childList) {
                String cName = (String) cMap.get("name");
                for (Map dMap : describeMap) {
                    String dName = (String) dMap.get("name");
                    if (cName.equals(dName)) {
                        cMap.put("describe", dMap.get("describe"));
                        break;
                    }
                }
            }
        }
        return maps;
    }

    @ApiOperation(value = "情报科技页面整合检索")
    @PostMapping("/complexSearch_qbkj")
    public Result complexSearch_qbkj(@RequestBody QBKJBo qbkjBo) {
        CutPageBean<QBKJPo> qbkjList = qbkjService.complexSearchQBKJ(qbkjBo);
        return Result.succ(qbkjList);
    }

}
